﻿<%@ Page Title="公司详细页" Language="C#" MasterPageFile="~/MasterPage/Detail.master" AutoEventWireup="true" CodeFile="detail.aspx.cs" Inherits="company_detail" %>

<%@ Register assembly="Back.Xinkui.Common" namespace="Back.Xinkui.Common.Control.Region" tagprefix="cc1" %>
<%@ Import Namespace="Xinkui.Common.Enum" %>
<%@ Import Namespace="Back.Xinkui.Common.Enum" %>
<asp:Content ID="Content1" ContentPlaceHolderID="headcss" Runat="Server">
<link href="/themes/default/css/layer.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.imgView li{float: left;height: 200px; margin-right: 5px;padding: 5px;width: 105px;}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<fieldset>
<legend>Basic Information</legend>
<table class="editTable" border="1" cellspacing="1" cellpadding="0" style="width: 100%;">
<tr>
    <th style="width:10%">Company Name：</th>
    <td style="width:40%"><asp:TextBox ID="txtCompanyName" runat="server" CssClass="inputText"></asp:TextBox></td>
    <th style="width:10%">公司名称（中文）：</th>
    <td style="width:40%"><asp:TextBox ID="txtCnCompanyName" runat="server" CssClass="inputText"></asp:TextBox></td>
</tr>
<tr>
    <th>Phone Num：</th>
    <td><asp:TextBox ID="txtCompanyPhone" runat="server" CssClass="inputText"></asp:TextBox></td>
    <th>Fax Num：</th>
    <td><asp:TextBox ID="txtCompanyFax" runat="server" CssClass="inputText"></asp:TextBox></td>
</tr>
<tr>
    <th>Email：</th>
    <td><asp:TextBox ID="txtCompanyEmail" runat="server" CssClass="inputText"></asp:TextBox></td>
    <th>WebSite：</th>
    <td><asp:TextBox ID="txtWebSite" runat="server" CssClass="inputText"></asp:TextBox></td>
</tr>
<tr>
    <th>Address：</th>
    <td colspan="3"><cc1:ApsotoRPC ID="ApsotoRPC1" runat="server" CssClass="selectAear" /><asp:TextBox ID="txtAddress" runat="server" Width="600px" CssClass="inputText"></asp:TextBox>  邮编：<asp:TextBox ID="txtPostCode" runat="server" Width="100px" CssClass="inputText"></asp:TextBox>
    </td>
</tr>
<tr>
    <th>Main Products：</th>
    <td colspan="3"><asp:TextBox ID="txtMainProduct" runat="server" CssClass="inputText"></asp:TextBox></td>
</tr>
<tr>
    <th>Descrtiption：</th>
    <td colspan="3"><asp:TextBox ID="txtCompanyDesc" runat="server" TextMode="MultiLine" Rows="5" CssClass="inputText"></asp:TextBox></td>
</tr>
<tr>
    <th>Logo：</th>
    <td><%--<%=imgCompanyLogo%><input type="button" value="upload" style="width:80px;" />--%>
        <asp:HiddenField ID="hidLogo" runat="server" />
        <asp:Image ID="viewLogo" runat="server" ImageUrl="~/Themes/default/images/Img/noimage.jpg" Width="100" />
        <a href="javascript:" onclick="uploadImg(<%=(int)ESourceType.FromCompanyLogo%>)">上传</a>
    </td>
    <th>Photo：</th>
    <td><%--<%=imgCompanyImage%><input type="button" value="upload" style="width:80px;"/>--%>
        <asp:HiddenField ID="hidImage" runat="server" />
        <asp:Image ID="viewImage" runat="server" ImageUrl="~/Themes/default/images/Img/noimage.jpg" Width="100" />
        <a href="javascript:" onclick="uploadImg(<%=(int)ESourceType.FromCompanyImage%>)">上传</a>
    </td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Bussiness Information</legend>
<table class="editTable" border="1" cellspacing="1" cellpadding="0" style="width: 100%;">
<tr>
    <th style="width:10%">Ownership Type：</th>
    <td style="width:40%">
        <asp:DropDownList ClientIDMode="static" ID="dropDownOwnership" runat="server">
        </asp:DropDownList>
    </td>
    <th style="width:10%">OE Experience：</th>
    <td style="width:40%"><asp:CheckBox ID="chkIsOE" runat="server" Text="Is OE Experience" /></td>
</tr>
<tr>
    <th>CEO：</th>
    <td><asp:TextBox ID="txtCeo" runat="server" CssClass="inputText"></asp:TextBox></td>
    <th>Year Established：</th>
    <td><asp:TextBox ID="txtYear" runat="server" CssClass="inputText"></asp:TextBox></td>
</tr>
<tr>
    <th>Total Annual Sales：</th>
    <td>
        <asp:DropDownList ClientIDMode="static" ID="dropDownSales" runat="server">
        </asp:DropDownList>
    </td>
    <th>Registered Capital：</th>
    <td>
        <asp:DropDownList ClientIDMode="static" ID="dropDownCapital" runat="server">
        </asp:DropDownList>
    </td>
</tr>
<tr>
    <th>Number of Employees：</th>
    <td>
        <asp:DropDownList ClientIDMode="static" ID="dropDownNumOfEmployees" runat="server">
        </asp:DropDownList>
    </td>
    <th>Number of R&amp;D Employees：</th>
    <td>
        <asp:DropDownList ClientIDMode="static" ID="dropDownNumberOfRDEmployees" runat="server">
        </asp:DropDownList>
    </td>
</tr>
<tr>
    <th>Typical Clients：</th>
    <td colspan="3"><asp:TextBox ID="txtTypical" runat="server" CssClass="inputText"></asp:TextBox><td>
</tr>
<tr>
    <th>Is Export：</th>
    <td>
      <asp:CheckBox ID="chkIsExport" runat="server" Text="Is Export" /></td>
    <th>Export Ratio：</th>
    <td>
        <asp:DropDownList ClientIDMode="static" ID="dropDownExportRatio" runat="server">
        </asp:DropDownList>
    </td>
</tr>
<tr>
    <th>Exprot Market：</th>
    <td colspan="3">
    <%foreach (var item in ExprotMarket)
      { %>
    <input name="chkMarket" <%=item.IsChecked?"checked=checked":"" %> type="checkbox" value="<%=item.Id %>" id="chkMarkt<%=item.Id %>"><label for="chkMarkt<%=item.Id %>"><%=item.Name %></label><%} %></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Contact Information</legend>
<table class="editTable" border="1" cellspacing="1" cellpadding="0" style="width: 100%;">
<tr>
    <th style="width:10%">Contact Person：</th>
    <td style="width:40%"><asp:TextBox ID="txtFirstName" runat="server" Width="100px" CssClass="inputText"></asp:TextBox><asp:TextBox ID="txtLastName" runat="server" Width="100px" CssClass="inputText"></asp:TextBox>
        <asp:RadioButton ID="rbtnMale" runat="server" Text="Male" GroupName="gender" CssClass="inputRadio"/>
        <asp:RadioButton ID="rbtnFemale" runat="server" Text="Female" GroupName="gender"/>
    </td>
    <th style="width:10%">LoginAccount：</th>
    <td style="width:40%"><asp:TextBox ID="txtUserName" runat="server" ReadOnly="true" CssClass="inputText"></asp:TextBox>
    </td>
</tr>
<tr>
    <th>Email：</th>
    <td><asp:TextBox ID="txtUserEmail" runat="server" CssClass="inputText"></asp:TextBox>
    </td>
    <th>Mobile：</th>
    <td ><asp:TextBox ID="txtUserMobile" runat="server" CssClass="inputText"></asp:TextBox>
    </td>
</tr>
<tr>
    <th>Department：</th>
    <td><asp:TextBox ID="txtDepartment" runat="server" CssClass="inputText"></asp:TextBox></td>
    <th>Job Title：</th>
    <td><asp:DropDownList ClientIDMode="static" ID="dropDownJobTitle" runat="server">
        </asp:DropDownList>
        </td>
</tr>
</table>
</fieldset>
<div style="text-align:center;">
<%if (CompanyID > 0 && AuditStatus != (int)EAuditStatus.Approve){ %>
    <asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="btn" 
        onclick="btnApprove_Click" />
<%} %>
<%if (AuditStatus != (int)EAuditStatus.Reject){ %>
    <asp:Button ID="btnSave" runat="server" Text="Save" CssClass="btn" 
        onclick="btnSave_Click" />
<%} %>
<%if (CompanyID > 0 && AuditStatus != (int)EAuditStatus.Reject){ %>
    <asp:Button ID="btnReject" runat="server" Text="Reject" CssClass="btn" 
        onclick="btnReject_Click" />
<%} %>

    <input type="button" value="Close" onclick="window.close();" class="btn" />
</div>
<%if (CompanyID > 0)
  { %>
<fieldset>
<legend>Certificate (<a href="javascript:" onclick="return showCert(0,null);">Add</a>)</legend>
<table class="editTable" border="1" cellspacing="1" cellpadding="0" style="width: 100%;">
    <tr>
       <td>
            <div class="imgView">
               <ul data-listidx="0" id="CertList">
               <asp:Repeater ID="rpCertList" runat="server">
               <ItemTemplate>
                    <li id="Cert_<%#Eval("CertID") %>"><img src="<%#Eval("viewImage") %>" width="100" />
                        <br /><span><%#Eval("CertName")%></span>
                        <br /><a href="javascript:" onclick="return showCert(<%#Eval("CertID") %>,this);">Edit</a>
                         <a href="javascript:" onclick="return deleteCert(<%#Eval("CertID") %>);">Delete</a>
                         <input type="hidden" value="<%#Eval("PicPath") %>" />
                    </li>
               </ItemTemplate>
               </asp:Repeater>
               </ul>
            </div>
       </td>
    </tr>
</table>
</fieldset>
<div id="divCert" style="display:none; z-index:999">
<div class="cont">
    <div class="purshasTextB">
    <table class="editTable" width="100%">
        <tr>
            <th style="width:30%">Certificate Name：</th>
            <td style="border-left:5"><input type="text" class="inputText" id="txtCertName" /></td>
        </tr>
        <tr>
            <th>Image:</th>
            <td><img src="/Themes/default/images/Img/noimage.jpg" id="viewImg" width="100" /><a href="javascript:" onclick="uploadImg(<%=(int)ESourceType.FromCertification %>)">上传</a>
            </td>
        </tr>
    </table>
    </div>
</div>
<div  align="center">
    <input onclick="saveCert();" value="Save" class="btn" type="button" />
    <input type="hidden" id="hidCertId" value="" />
    <input type="hidden" id="hidPicPath" value="" />
</div>
</div>

<fieldset>
<legend>Equipment (<a href="javascript:" onclick="return showEquipment(0,null);">Add</a>)</legend>
<table class="editTable" border="1" cellspacing="1" cellpadding="0" style="width: 100%;">
    <tr>
       <td>
            <div class="imgView">
               <ul data-listidx="0" id="EquipmentList">
               <asp:Repeater ID="rpEquipmentList" runat="server">
               <ItemTemplate>
                    <li id="Equi_<%#Eval("EquipmentID") %>"><img src="<%#Eval("viewImage") %>" width="100" />
                        <br /><span><%#Eval("EquipmentName")%></span>
                        <br /><a href="javascript:" onclick="return showEquipment(<%#Eval("EquipmentID") %>,this);">Edit</a>
                         <a href="javascript:" onclick="return deleteEquipment(<%#Eval("EquipmentID") %>);">Delete</a>
                         <input type="hidden" value="<%#Eval("PicPath") %>" />
                    </li>
               </ItemTemplate>
               </asp:Repeater>
               </ul>
            </div>
       </td>
    </tr>
</table>
</fieldset>
<div id="divEquipment" style="display:none; z-index:999">
<div class="cont">
    <div class="purshasTextB">
    <table class="editTable" width="100%">
        <tr>
            <th style="width:30%">Equipment Name：</th>
            <td style="border-left:5"><input type="text" class="inputText" id="txtEquipmentName" /></td>
        </tr>
        <tr>
            <th>Image:</th>
            <td><img src="/Themes/default/images/Img/noimage.jpg" id="viewImg" width="100" /><a href="javascript:" onclick="uploadImg(<%=(int)ESourceType.FromEquipment %>)">上传</a>
            </td>
        </tr>
    </table>
    </div>
</div>
<div  align="center">
    <input onclick="saveEquipment();" value="Save" class="btn" type="button" />
    <input type="hidden" id="hidEquipmentID" value="" />
    <input type="hidden" id="hidEquipmentPicPath" value="" />
</div>
</div>
<%} %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" Runat="Server">
<script src="/js/mainform/base.js" type="text/javascript"></script>
<script type="text/javascript">
<%if(CompanyID > 0){ %>
    function showCert(certId,obj) {
        $Layer.Reset();
        $Layer.IsBack = false;
        $Layer.IsFooter = false;
        $Layer.Width = 640;
        $Layer.Title = "Edit Certificate";
        $Layer.CloseText = "Close";
        $Layer.Content = $("#divCert").html();
        $Layer.IsConfirm = true;
        $Layer.Confirm.Text = "确 定";
        $Layer.Confirm.Event = ""
        $Layer.Open();
        if(obj != null){
            if ($(obj).siblings("img").attr("src").length > 0) {
                $("#showBox").find("#viewImg").attr("src", $(obj).siblings("img").attr("src"));
            }
            $("#showBox").find("#txtCertName").val($(obj).siblings("span").text());
            $("#showBox").find("#hidCertId").val(certId);
            $("#showBox").find("#hidPicPath").val($(obj).siblings("input").val());
        }
        return false;
    }

    function deleteCert(certId){
        if(confirm("Are You Sure?")){
            $.post("certDelete.ashx",{certId:certId},function(rValue){
                if(rValue != "-1"){
                    var certLi = $("#CertList").find("#Cert_"+ certId);
                    certLi.remove();
                }
            });
        }
    }
    function saveCert() {
        var postCert = {
            CertId:$("#showBox").find("#hidCertId").val(),
            CertName:$("#showBox").find("#txtCertName").val(),
            PicPath:$("#showBox").find("#hidPicPath").val(),
            CompanyId:<%=CompanyID %>
        };
        $.post("certSave.ashx",postCert,function(rValue){
            if(rValue != "-1"){
                var certLi = $("#CertList").find("#Cert_"+ rValue);
                var viewHtml = '<li id="Cert_'+rValue+'"><img src="'+$("#showBox").find("#viewImg").attr("src")+'" width="100" /><br/><span>'+postCert.CertName+'</span><br /><a href="javascript:" onclick="return showCert('+rValue+',this);">Edit</a> <a href="javascript:" onclick="return deleteCert('+rValue+');">Delete</a></li>';
                if(certLi.length > 0){
                    certLi.html(viewHtml);
                }else{
                    $("#EquipmentList").prepend(viewHtml);
                }
                $Layer.Close();
            }
        });
    }
    function showEquipment(equipmentId,obj) {
        $Layer.Reset();
        $Layer.IsBack = false;
        $Layer.IsFooter = false;
        $Layer.Width = 640;
        $Layer.Title = "Edit Equipment";
        $Layer.CloseText = "Close";
        $Layer.Content = $("#divEquipment").html();
        $Layer.IsConfirm = true;
        $Layer.Confirm.Text = "确 定";
        $Layer.Confirm.Event = ""
        $Layer.Open();
        if(obj != null){
            if ($(obj).siblings("img").attr("src").length > 0) {
                $("#showBox").find("#viewImg").attr("src", $(obj).siblings("img").attr("src"));
            }
            $("#showBox").find("#txtEquipmentName").val($(obj).siblings("span").text());
            $("#showBox").find("#hidEquipmentID").val(equipmentId);
            $("#showBox").find("#hidEquipmentPicPath").val($(obj).siblings("input").val());
        }
        return false;
    }

    function deleteEquipment(equipmentId){
        if(confirm("Are You Sure?")){
            $.post("equiDelete.ashx",{equipmentId:equipmentId},function(rValue){
                if(rValue != "-1"){
                    var certLi = $("#EquipmentList").find("#Equi_"+ equipmentId);
                    certLi.remove();
                }
            });
        }
    }
    function saveEquipment() {
        var postCert = {
            EquipmentID:$("#showBox").find("#hidEquipmentID").val(),
            EquipmentName:$("#showBox").find("#txtEquipmentName").val(),
            PicPath:$("#showBox").find("#hidEquipmentPicPath").val(),
            CompanyId:<%=CompanyID %>
        };
        $.post("equiSave.ashx",postCert,function(rValue){
            if(rValue != "-1"){
                var certLi = $("#EquipmentList").find("#Equi_"+ rValue);
                var viewHtml = '<li id="Equi_'+rValue+'"><img src="'+$("#showBox").find("#viewImg").attr("src")+'" width="100" /><br/><span>'+postCert.EquipmentName+'</span><br /><a href="javascript:" onclick="return showEquipment('+rValue+',this);">Edit</a> <a href="javascript:" onclick="return deleteEquipment('+rValue+');">Delete</a></li>';
                if(certLi.length > 0){
                    certLi.html(viewHtml);
                }else{
                    $("#EquipmentList").prepend(viewHtml);
                }
                $Layer.Close();
            }
        });

    }

    <%} %>
    function uploadSuccess(varFile) {
        switch (varFile.SourceType) {
            case 1:
                uploadComLogo(varFile);
                break;
            case 2:
                uploadComImage(varFile);
            case 5:
                uploadCertImg(varFile);
                break;
            case 6:
                uploadEquiImg(varFile);
                break;
        }
    }
    function uploadComLogo(varFile) {
        $("#<%=viewLogo.ClientID%>").attr("src", varFile.ImageUrl);
        $("#<%=hidLogo.ClientID%>").val(varFile.SavePath);
    }
    function uploadComImage(varFile) {
        $("#<%=viewImage.ClientID%>").attr("src", varFile.ImageUrl);
        $("#<%=hidImage.ClientID%>").val(varFile.SavePath);
    }
    function uploadEquiImg(varFile) {
        $("#showBox").find("#viewImg").attr("src", varFile.ImageUrl);
        $("#showBox").find("#hidEquipmentPicPath").val(varFile.SavePath);
    }
    function uploadCertImg(varFile) {
        $("#showBox").find("#viewImg").attr("src", varFile.ImageUrl);
        $("#showBox").find("#hidPicPath").val(varFile.SavePath);
    }

    function uploadImg(sType) {
        OpenWindow("/Upload.aspx?sType=" + sType, 300, 50); 
    }

</script>
</asp:Content>

